package android.support.v4.app;

import android.util.Log;
import java.io.PrintWriter;
import java.util.ArrayList;

final class a extends t
  implements Runnable
{
  final m a;
  b b;
  b c;
  int d;
  int e;
  int f;
  int g;
  int h;
  int i;
  int j;
  boolean k;
  boolean l = true;
  String m;
  boolean n;
  int o = -1;
  int p;
  CharSequence q;
  int r;
  CharSequence s;

  public a(m paramm)
  {
    this.a = paramm;
  }

  public final int a()
  {
    if (this.n)
      throw new IllegalStateException("commit already called");
    if (m.a)
    {
      Log.v("FragmentManager", "Commit: " + this);
      a("  ", new PrintWriter(new android.support.v4.c.b("FragmentManager")));
    }
    this.n = true;
    if (this.k);
    for (this.o = this.a.a(this); ; this.o = -1)
    {
      this.a.a(this);
      return this.o;
    }
  }

  public final t a(int paramInt, Fragment paramFragment, String paramString)
  {
    paramFragment.s = this.a;
    if (paramString != null)
    {
      if ((paramFragment.y != null) && (!(paramString.equals(paramFragment.y))))
        throw new IllegalStateException("Can't change tag of fragment " + paramFragment + ": was " + paramFragment.y + " now " + paramString);
      paramFragment.y = paramString;
    }
    if (paramInt != 0)
    {
      if ((paramFragment.w != 0) && (paramFragment.w != paramInt))
        throw new IllegalStateException("Can't change container ID of fragment " + paramFragment + ": was " + paramFragment.w + " now " + paramInt);
      paramFragment.w = paramInt;
      paramFragment.x = paramInt;
    }
    paramString = new b();
    paramString.c = 1;
    paramString.d = paramFragment;
    a(paramString);
    return this;
  }

  public final t a(Fragment paramFragment)
  {
    b localb = new b();
    localb.c = 6;
    localb.d = paramFragment;
    a(localb);
    return this;
  }

  final void a(int paramInt)
  {
    if (!(this.k))
      return;
    if (m.a)
      Log.v("FragmentManager", "Bump nesting in " + this + " by " + paramInt);
    for (b localb = this.b; ; localb = localb.a)
    {
      Fragment localFragment;
      if (localb != null);
      if (localb.d != null)
      {
        localFragment = localb.d;
        localFragment.r += paramInt;
        if (m.a)
          Log.v("FragmentManager", "Bump nesting of " + localb.d + " to " + localb.d.r);
      }
      if (localb.i == null)
        continue;
      int i1 = localb.i.size() - 1;
      while (i1 >= 0)
      {
        localFragment = (Fragment)localb.i.get(i1);
        localFragment.r += paramInt;
        if (m.a)
          Log.v("FragmentManager", "Bump nesting of " + localFragment + " to " + localFragment.r);
        i1 -= 1;
      }
    }
  }

  final void a(b paramb)
  {
    if (this.b == null)
    {
      this.c = paramb;
      this.b = paramb;
    }
    while (true)
    {
      paramb.e = this.e;
      paramb.f = this.f;
      paramb.g = this.g;
      paramb.h = this.h;
      this.d += 1;
      return;
      paramb.b = this.c;
      this.c.a = paramb;
      this.c = paramb;
    }
  }

  public final void a(String paramString, PrintWriter paramPrintWriter)
  {
    a(paramString, paramPrintWriter, true);
  }

  public final void a(String paramString, PrintWriter paramPrintWriter, boolean paramBoolean)
  {
    if (paramBoolean)
    {
      paramPrintWriter.print(paramString);
      paramPrintWriter.print("mName=");
      paramPrintWriter.print(this.m);
      paramPrintWriter.print(" mIndex=");
      paramPrintWriter.print(this.o);
      paramPrintWriter.print(" mCommitted=");
      paramPrintWriter.println(this.n);
      if (this.i != 0)
      {
        paramPrintWriter.print(paramString);
        paramPrintWriter.print("mTransition=#");
        paramPrintWriter.print(Integer.toHexString(this.i));
        paramPrintWriter.print(" mTransitionStyle=#");
        paramPrintWriter.println(Integer.toHexString(this.j));
      }
      if ((this.e != 0) || (this.f != 0))
      {
        paramPrintWriter.print(paramString);
        paramPrintWriter.print("mEnterAnim=#");
        paramPrintWriter.print(Integer.toHexString(this.e));
        paramPrintWriter.print(" mExitAnim=#");
        paramPrintWriter.println(Integer.toHexString(this.f));
      }
      if ((this.g != 0) || (this.h != 0))
      {
        paramPrintWriter.print(paramString);
        paramPrintWriter.print("mPopEnterAnim=#");
        paramPrintWriter.print(Integer.toHexString(this.g));
        paramPrintWriter.print(" mPopExitAnim=#");
        paramPrintWriter.println(Integer.toHexString(this.h));
      }
      if ((this.p != 0) || (this.q != null))
      {
        paramPrintWriter.print(paramString);
        paramPrintWriter.print("mBreadCrumbTitleRes=#");
        paramPrintWriter.print(Integer.toHexString(this.p));
        paramPrintWriter.print(" mBreadCrumbTitleText=");
        paramPrintWriter.println(this.q);
      }
      if ((this.r != 0) || (this.s != null))
      {
        paramPrintWriter.print(paramString);
        paramPrintWriter.print("mBreadCrumbShortTitleRes=#");
        paramPrintWriter.print(Integer.toHexString(this.r));
        paramPrintWriter.print(" mBreadCrumbShortTitleText=");
        paramPrintWriter.println(this.s);
      }
    }
    if (this.b == null)
      return;
    paramPrintWriter.print(paramString);
    paramPrintWriter.println("Operations:");
    String str2 = paramString + "    ";
    b localb = this.b;
    int i1 = 0;
    while (localb != null)
    {
      int i2;
      String str1;
      switch (localb.c)
      {
      default:
        str1 = "cmd=" + localb.c;
        paramPrintWriter.print(paramString);
        paramPrintWriter.print("  Op #");
        paramPrintWriter.print(i1);
        paramPrintWriter.print(": ");
        paramPrintWriter.print(str1);
        paramPrintWriter.print(" ");
        paramPrintWriter.println(localb.d);
        if (paramBoolean)
        {
          if ((localb.e != 0) || (localb.f != 0))
          {
            paramPrintWriter.print(paramString);
            paramPrintWriter.print("enterAnim=#");
            paramPrintWriter.print(Integer.toHexString(localb.e));
            paramPrintWriter.print(" exitAnim=#");
            paramPrintWriter.println(Integer.toHexString(localb.f));
          }
          if ((localb.g != 0) || (localb.h != 0))
          {
            paramPrintWriter.print(paramString);
            paramPrintWriter.print("popEnterAnim=#");
            paramPrintWriter.print(Integer.toHexString(localb.g));
            paramPrintWriter.print(" popExitAnim=#");
            paramPrintWriter.println(Integer.toHexString(localb.h));
          }
        }
        if ((localb.i != null) && (localb.i.size() > 0))
        {
          i2 = 0;
          if (i2 < localb.i.size())
          {
            paramPrintWriter.print(str2);
            if (localb.i.size() == 1)
              paramPrintWriter.print("Removed: ");
          }
        }
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      }
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              while (true)
              {
                while (true)
                {
                  while (true)
                  {
                    while (true)
                    {
                      while (true)
                      {
                        while (true)
                        {
                          paramPrintWriter.println(localb.i.get(i2));
                          i2 += 1;
                        }
                        str1 = "NULL";
                      }
                      str1 = "ADD";
                    }
                    str1 = "REPLACE";
                  }
                  str1 = "REMOVE";
                }
                str1 = "HIDE";
              }
              str1 = "SHOW";
            }
            str1 = "DETACH";
          }
          str1 = "ATTACH";
        }
        if (i2 == 0)
          paramPrintWriter.println("Removed:");
        paramPrintWriter.print(str2);
        paramPrintWriter.print("  #");
        paramPrintWriter.print(i2);
        paramPrintWriter.print(": ");
      }
      localb = localb.a;
      i1 += 1;
    }
  }

  public final t b(Fragment paramFragment)
  {
    b localb = new b();
    localb.c = 7;
    localb.d = paramFragment;
    a(localb);
    return this;
  }

  public final void run()
  {
    if (m.a)
      Log.v("FragmentManager", "Run: " + this);
    if ((this.k) && (this.o < 0))
      throw new IllegalStateException("addToBackStack() called after commit()");
    a(1);
    b localb = this.b;
    if (localb != null)
    {
      switch (localb.c)
      {
      default:
        throw new IllegalArgumentException("Unknown cmd: " + localb.c);
      case 1:
        localObject1 = localb.d;
        ((Fragment)localObject1).G = localb.e;
        this.a.a((Fragment)localObject1, false);
      case 2:
      case 3:
      case 4:
      case 5:
      case 6:
      case 7:
      }
      while (true)
      {
        while (true)
          localb = localb.a;
        localObject1 = localb.d;
        if (this.a.g != null)
        {
          int i1 = 0;
          localObject2 = localObject1;
          if (i1 >= this.a.g.size())
            break label431;
          Fragment localFragment = (Fragment)this.a.g.get(i1);
          if (m.a)
            Log.v("FragmentManager", "OP_REPLACE: adding=" + localObject1 + " old=" + localFragment);
          if (localObject1 != null)
          {
            localObject2 = localObject1;
            if (localFragment.x != ((Fragment)localObject1).x)
              break label297;
          }
          if (localFragment == localObject1)
          {
            localObject2 = null;
            localb.d = null;
          }
          while (true)
          {
            while (true)
            {
              label297: i1 += 1;
              localObject1 = localObject2;
            }
            if (localb.i == null)
              localb.i = new ArrayList();
            localb.i.add(localFragment);
            localFragment.G = localb.f;
            if (this.k)
            {
              localFragment.r += 1;
              if (m.a)
                Log.v("FragmentManager", "Bump nesting of " + localFragment + " to " + localFragment.r);
            }
            this.a.a(localFragment, this.i, this.j);
            localObject2 = localObject1;
          }
        }
        Object localObject2 = localObject1;
        label431: if (localObject2 == null)
          continue;
        localObject2.G = localb.e;
        this.a.a(localObject2, false);
        continue;
        localObject1 = localb.d;
        ((Fragment)localObject1).G = localb.f;
        this.a.a((Fragment)localObject1, this.i, this.j);
        continue;
        localObject1 = localb.d;
        ((Fragment)localObject1).G = localb.f;
        this.a.b((Fragment)localObject1, this.i, this.j);
        continue;
        localObject1 = localb.d;
        ((Fragment)localObject1).G = localb.e;
        this.a.c((Fragment)localObject1, this.i, this.j);
        continue;
        localObject1 = localb.d;
        ((Fragment)localObject1).G = localb.f;
        this.a.d((Fragment)localObject1, this.i, this.j);
        continue;
        localObject1 = localb.d;
        ((Fragment)localObject1).G = localb.e;
        this.a.e((Fragment)localObject1, this.i, this.j);
      }
    }
    this.a.a(this.a.n, this.i, this.j, true);
    if (!(this.k))
      return;
    Object localObject1 = this.a;
    if (((m)localObject1).i == null)
      ((m)localObject1).i = new ArrayList();
    ((m)localObject1).i.add(this);
    ((m)localObject1).e();
  }

  public final String toString()
  {
    StringBuilder localStringBuilder = new StringBuilder(128);
    localStringBuilder.append("BackStackEntry{");
    localStringBuilder.append(Integer.toHexString(System.identityHashCode(this)));
    if (this.o >= 0)
    {
      localStringBuilder.append(" #");
      localStringBuilder.append(this.o);
    }
    if (this.m != null)
    {
      localStringBuilder.append(" ");
      localStringBuilder.append(this.m);
    }
    localStringBuilder.append("}");
    return localStringBuilder.toString();
  }
}